/**
 * 
 */
package com.gordon.tips.util;

import java.text.SimpleDateFormat;
import java.util.Date;

/**
 *****************************************************************************
 ** Module : Render the web page in good-looking pattern
 ** 
 ** Date:  Aug 16th,2011
 ** 
 ** Author: Gordon
 ** 
 ** Email: 462991284@qq.com
 ** 
 ** (C) Copyright 2011 Gordon Office
 *****************************************************************************
 */

public class RenderUtil {
	
	public static String getDateDisplay(Date date)
	{
		Date now=new Date();
		if(now.getTime()-date.getTime()<60*1000)//in 1 minute
			return ( (now.getTime()-date.getTime())/1000)+" seconds ago";
		else if(now.getTime()-date.getTime()<60*1000*60)//in 1 hour
			return  ( (now.getTime()-date.getTime())/1000/60)+" minutes ago";
		else if(now.getTime()-date.getTime()<60*1000*60*24)//in 1 day
			return  ( (now.getTime()-date.getTime())/1000/60/60)+" hours ago";
		else if(now.getTime()-date.getTime()<60*1000*60*48)//yesterday
			return  "Yesterday";
		else if(now.getTime()-date.getTime()<60*1000*60*24*7)//in a week
			return  ( (now.getTime()-date.getTime())/1000/60/24/60)+" days ago";
		else		
			return new SimpleDateFormat("yyyy-MM-dd").format(date);		
	}

}
